package com.bwie.chenzihang.service;
import android.app.Service;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Binder;
import android.os.IBinder;

public class Service4 extends Service {
    public Service4() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return new MyBind();
    }

    public class MyBind extends Binder {
        public boolean setText(String name, String pwd) {
            return checkUser(name, pwd);
        }
    }

    private boolean checkUser(String name, String pwd) {
        UserDB2 userDB2 = new UserDB2(this);
        SQLiteDatabase db = userDB2.getReadableDatabase();
        Cursor user = db.query("user", null, "username=? and password=?",
                new String[]{name, pwd}, null, null, null);
        if (user != null && user.getCount() > 0) {
            user.close();
            return true;
        } else {
            return false;
        }
    }
}